#include<stdio.h>

int m[100][100]={0};
int main()
{
	int n,flag,sign,key=0;
	scanf("%d",&n);
	for(sign=0;sign<n;sign++)
	{
		for(flag=0;flag<n;flag++)
		{
			scanf("%d",&m[sign][flag]);
		}
	}
	int hang=0,lie=0;
	for(sign=0;sign<n*n;sign++)
	{
		if(sign==0)
		{
			printf("%d",m[hang][lie]);
			key=1;
			if(sign<n*n-1) printf(" ");
			continue;
		}
		if(key==1)
		{
			lie++;
			printf("%d",m[hang][lie]);
			if(hang==0) key=2;
			if(hang==n-1) key=4;
			if(sign<n*n-1) printf(" ");
			continue;
		}
		if(key==2)
		{
			hang++;
			lie--;
			printf("%d",m[hang][lie]);
			if(lie==0&&hang!=n-1) key=3;
			if(hang==n-1) key=1;
			if(sign<n*n-1) printf(" ");
			continue;
		}
		if(key==3)
		{
			hang++;
			printf("%d",m[hang][lie]);
			if(lie==0) key=4;
			if(lie==n-1) key=2;
			if(sign<n*n-1) printf(" ");
			continue;
		}
		if(key==4)
		{
			hang--;
			lie++;
			printf("%d",m[hang][lie]);
			if(hang==0&&lie!=n-1) key=1;
			if(lie==n-1) key=3;
			if(sign<n*n-1) printf(" ");
			continue;
		}	
	}
	return 0;
}
